<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php echo $commander->getListCommandsPanel('s', ''); ?>
<div class="menu_list">
	<table style="clear:both;" id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
        <thead class="fields">
            <tr>
                <th class="first center">&nbsp;&nbsp;Id&nbsp;&nbsp;</th>
                <th><?php echo ucfirst($txt->getWord('name')); ?></th>
                <th class="last"><?php echo ucfirst($txt->getWord('edit')); ?></th>
            </tr>
        </thead>
        <tbody>
        	<tr class="items">
	            <td class="first center">#</td>
	            <td>
                	 <select id="add_group_id" name="add_group_id" class="medium">
                        <option value="0"><?php echo ucfirst($txt->getWord('select')).' '.$txt->getWord('productgroup'); ?></option>
                        <?php
                        foreach($shop->getGroups() as $group)
                        {
                            if(!($shop->CurrentProvider->getGroup($group->getId())))
                            {  echo '<option value="'.$group->getId().'" >'.$group->getTitle().'</option>';  }
                        }
                        ?>
                    </select>&nbsp;
                </td>
	            <td class="last"><img title="<?php echo ucfirst($txt->getWord('add')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>add_16.gif"  onclick="edit_form.submit();" /></td>
	        </tr>
            <?php 
			if($shop->CurrentProvider->getGroups())
			{
				foreach($shop->CurrentProvider->getGroups() as $group)
				{
				?>
				<tr class="items">
					<td class="first center"><?php echo $group->getId(); ?><input type="hidden" name="group_id[]" value="<?php echo $group->getId(); ?>" /></td>
					<td><input class="medium" name="group_title[]" type="text" value="<?php echo $group->getTitle(); ?>" maxlength="80" /></td>
					<td class="last">
					<img title="<?php echo ucfirst($txt->getWord('remove').' '.$txt->getWord('group')); ?>" class="icon command group_delete" src="<?php echo SYSICONS_URL; ?>delete_16.gif" onclick="deleteDialogGroup(<?php echo $group->getId(); ?>);" />
					</td>
				</tr>
				<?php
            	}
			}
            ?>
        </tbody>
    </table>
    <input type="hidden" name="rem_group_id" id="rem_group_id" value="0" />
</div>
<script type="text/javascript">
function deleteDialogGroup(itemId)
{
	jQuery('#delete_dialog_group').dialog('open');
	jQuery('#delete_dialog_group').dialog({
		bgiframe: true,
		resizable: false,
		height:140,
		modal: true,
		overlay: 
		{
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: 
		{
			'<?php echo ucfirst($txt->getWord('no')); ?>': function() 
			{
				jQuery(this).dialog('close');
			},
			'<?php echo ucfirst($txt->getWord('remove')).' '.$txt->getWord('element'); ?>': function() 
			{
				jQuery('#rem_group_id').val(itemId);
				jQuery(this).dialog('close');
				jQuery('#edit_form').submit();
			}
		}
	});
}
</script>
<div id="delete_dialog_group" title="<?php echo ucfirst($txt->getWord('remove').' '.$txt->getWord('group')); ?>?" style="display:none; text-align:left;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo ucfirst($txt->getWord('sure_you_want_to_delete')); ?></p>
</div>